package demo2;

import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Home-pc
 * Date: 2023-08-23
 * Time: 15:52
 */
public class Test1 {
    public static void main(String[] args) {
        BinaryTree binaryTree1=new BinaryTree();
        BinaryTree.TreeNode root=binaryTree1.createTree();

        binaryTree1.preOrder(root);
        System.out.println();

        System.out.println(binaryTree1.preorderTraversal(root));
        System.out.println("下面是中序遍历");
        binaryTree1.inOrder(root);
        System.out.println();
        System.out.println("下面是后序遍历");
        binaryTree1.postOrder(root);
        System.out.println();
        System.out.println("输出节点的个数");
        System.out.println(binaryTree1.size(root));
        System.out.println(binaryTree1.size2(root));
        System.out.println();
        System.out.println("输出叶子节点的个数");
        System.out.println(binaryTree1.getLeafNodeCount(root));
        System.out.println(binaryTree1.getLeafNodeCount2(root));
        System.out.println("输出第k层节点的个数");
        System.out.println(binaryTree1.getKLevelNodeCount(root, 3));
        System.out.println("输出树的高度");
        System.out.println(binaryTree1.getHeight(root));
        System.out.println("检查树中是否有某个元素");
        System.out.println(binaryTree1.find(root, 'D').val);
        System.out.println("层序遍历");
        binaryTree1.levelOrder(root);
        System.out.println();
        System.out.println("判断是否为一颗完全二叉树");
        System.out.println(binaryTree1.isComplete(root));
        System.out.println("获取路径");
        Stack<BinaryTree.TreeNode> stack=new Stack<>();
        System.out.println(binaryTree1.getpath(root, root.left.right, stack));
        System.out.println(binaryTree1.lowestCommonAncestor2(root, root.left, root.left.right).val);
    }
}
